//
//  UIImage+ZXExtension.m
//  ZXOCWeiBo
//
//  Created by mac on 15/11/30.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "UIImage+ZXExtension.h"

@implementation UIImage (ZXExtension)

+(instancetype)imageWithName:(NSString *)imgName
{
    if ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)
    {
        NSString * ios7ImgName = [imgName stringByAppendingString:@"_ios7"];
        return [UIImage imageNamed:ios7ImgName];
    }
    
    return [UIImage imageNamed:imgName];
}

/**
 *  自动从中间拉伸图片
 *
 *  @param imgName 图片名字
 */
+(instancetype)resizeImageWithName:(NSString *)imgName
{
    UIImage * img = [UIImage imageNamed:imgName];
    return [img stretchableImageWithLeftCapWidth:img.size.width * 0.5 topCapHeight:img.size.height * 0.5];
}

@end
